﻿using FlowerShop.Core.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLL.Services
{
    public class UserService
    {
        private readonly Model1 _context;

        public UserService()
        {
            _context = new Model1();
        }

        // 为t_user类型用户验证登录
        // 为t_user类型用户验证登录
        public t_user ValidateUserCredentials(string username, int password)
        {
            return _context.t_user.FirstOrDefault(u => u.username == username && u.pwd == password);
        }

        // 为Tpeople类型用户验证登录
        public Tpeople ValidatePeopleCredentials(string username, int password)
        {
            return _context.Tpeople.FirstOrDefault(p => p.t_name == username && p.t_mima == password);
        }

        // 为Twoker类型用户验证登录
        public Twoker ValidateWorkerCredentials(string username, int password)
        {
            return _context.Twoker.FirstOrDefault(w => w.t_name == username && w.phone == password);
        }

        public object ValidateUserCredentials(object username, int v)
        {
            throw new NotImplementedException();
        }
    }
    public enum UserType
    {
        Tpeople,
        Twoker,
        Tuser
    }
}
